package com.guigu.tomcat.impl;

import com.guigu.tomcat.HttpServletRequest;
import com.guigu.tomcat.HttpServletResponse;
import com.guigu.tomcat.ServletException;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LoginServlet extends HttpServletImpl{
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    /*   String uri = request.getRequestURI();
        System.out.println(uri);
        String params ;
        String name;
            params = uri.substring( uri.indexOf("?")+1);
//            System.out.println(params);
                String[] items = params.split("&");
                String params1=items[0];
                String[] item =params1.split("=");
                name = item[1];
              System.out.println(name);
//                name =new String(new  String(name.getBytes("ISO8859-1"),"utf-8").getBytes(),"UTF-8");
//                System.out.println(name);*/
        PrintWriter writer = response.getWriter();
        String name =request.getParameter("name");
        response.setContentType("text/html;charset=utf-8");
        //相应对象会临时保存append的内容
        writer.append("<h2>用户"+ name +"登录成功</h2>");



    }

    @Override
    public void init() {

    }

    @Override
    public void destroy() {

    }
}
